Fix generic lookups and thunks#129825
Open
davidwrighton wants to merge 7 commits into
Open
Conversation
Contributor
|
Tagging subscribers to this area: @agocke |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the WebAssembly ReadyToRun (R2R) pipeline to support generic dictionary lookups and related delay-load helper paths using the “DynamicHelper” pattern already used on other architectures, including adding dedicated Wasm .S helpers and updating Crossgen2’s Wasm thunk/signature plumbing accordingly.
Changes:
- Add new Wasm dynamic helper stubs (in
.S) for generic dictionary lookup variants and supporting VM glue to allocate the corresponding portable-entrypoint stub data. - Update Wasm delay-load/import thunk generation to support generic lookups via portable entrypoints (signature updates + always generating a thunk).
- Add missing Wasm portable-entrypoint interpreter-call thunks for additional signatures (e.g.,
doublearg +i32/i64return, andS8payload).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/wasm/helpers.cpp | Adds additional portable-entrypoint interpreter-call thunks and updates the portable-entrypoint thunk table; removes Wasm placeholder DelayLoad_Helper stubs. |
| src/coreclr/vm/wasm/dynamichelpers.S | New Wasm assembly implementations of generic dictionary lookup dynamic helpers (incl. size-check / null-test variants and small constant-offset fast paths). |
| src/coreclr/vm/wasm/dynamichelpers.cpp | Implements Wasm DelayLoad_Helper entry and creates portable-entrypoint data for generic dictionary lookup helpers on Wasm. |
| src/coreclr/vm/wasm/asmconstants.h | Introduces Wasm-specific asm constants/offsets needed by dynamichelpers.S (with debug/fre handling and static-assert hooks). |
| src/coreclr/vm/readytoruninfo.h | Adds GenericDictionaryDynamicHelperStubData_PortableEntryPoint layout used by Wasm helper stubs. |
| src/coreclr/vm/prestub.cpp | Allows resolving import sections by RVA when sectionIndex == (DWORD)-1 (used by Wasm delay-load helper), and excludes non-Wasm fixup kinds under TARGET_WASM. |
| src/coreclr/vm/jitinterface.cpp | Adds a debug assert ensuring portable-entrypoint targets have actual code under R2R (helps catch missing cases). |
| src/coreclr/vm/CMakeLists.txt | Wires new Wasm .S and .cpp sources (and asmconstants header) into the VM build. |
| src/coreclr/vm/cgensys.h | Adjusts DelayLoad_Helper declaration for Wasm to match the new calling convention/signature. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../WasmImportThunkPortableEntrypoint.cs | Updates generic-lookup thunk signature shape/string to include the portable-entrypoint parameter. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/.../DelayLoadHelperImport.cs | Always generates a Wasm import-thunk portable entrypoint (including for generic lookups). |
| eng/native/configurecompiler.cmake | Enables ASM for Browser/WASI toolchains so preprocessed Wasm .S files can be assembled by clang-based toolchains. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This was referenced Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for generic lookups to Wasm R2R code by following the DynamicHelper pattern we use on other platforms. This looks like a quite suitable implementation for Wasm, so I expect that this will remain for the long term.
Add support for WebAssembly .S files, as it was difficult to implement the helpers in inline assembly due to clang limitations.
Tweak Crossgen2 into generating uses of the DynamicHelper logic.
Also add support for precomputed thunks for various runtime helpers which were missing them, and add an assert that will fire even in interpreted runs for missing cases.
Fixes (most) of #129622
Fixes #129821